package stringdemo;

import java.util.Scanner;

public class StringDemo2 {
    public static void main(String[] args) {
        //1.定义两个正确的用户名和密码
        String rightUsername = "zhangsan";
        String rightPassword = "123456";

        //2.键盘录入用户名和密码
        Scanner sc = new Scanner(System.in);


        //3.比较
        int count = 3;
        while(count != 0){
            System.out.println("请输入用户名");
            String username = sc.next();
            System.out.println("请输入密码");
            String password = sc.next();
            if(rightUsername.equals(username) && rightPassword.equals(password)){
                System.out.println("成功登录");
                break;
            }else{
                if(count == 1){
                    System.out.println("账号"+ rightUsername + "被锁定，请联系客服");
                }else{
                    System.out.println("用户登陆失败，用户名或密码错误，你还有"+ (count-1) + "次机会");
                }
            }

            count--;
        }

    }
}
